package com.bolehui.web;

import com.bolehui.base.result.Result;
import com.bolehui.service.iSys.ISysDictDataService;
import com.bolehui.service.iSys.ISysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName SysDictDataController
 * @Description
 * @createTime 2025/2/27-15:22
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController {

    @Autowired
    private ISysDictDataService dictDataService;
    @Autowired
    private ISysDictTypeService dictTypeService;

    /**
     * 根据字典类型查询字典数据
     *
     * @param dictType 字典类型
     * @return 字典数据集合信息
     */
    @RequestMapping(params = "action=getDictDataByType")
    public Result getDictDataByType(String dictType){
        return dictTypeService.getDictDataByType(dictType);
    }

    /**
     * 根据父id查询下级数据
     * @param parentId
     * @return
     */
    @RequestMapping(params = "action=getDictDataById")
    public Result getDictDataById(String parentId){
        return dictDataService.getDictDataById(parentId);
    }

    @RequestMapping(params = "action=getDomain")
    public Result getDomain(String dictType){
        return dictTypeService.getDomain(dictType);
    }

    @RequestMapping(params ="action=getByCode")
    public Result getByDictCode(Long id){
        return Result.success(dictDataService.getById(id));

    }
}
